import 'package:flutter_jd/tools/data/mock.dart';
import 'package:flutter_jd/tools/utils/library.dart';
import 'package:get/get_state_manager/get_state_manager.dart';
import 'package:get/state_manager.dart';

class MyController extends GetxController {
  //滚动最大距离
  double appBarScrollOffset = 100;
  // 透明值
  final appBarAlpha = RxDouble(0);
  int currentPageIndex = 0;
  final goodsList = PRODUCT_LIST.obs;
  var eventBus = new EventBus();

  @override
  void onInit() {
    super.onInit();
  }

  List topList = [
    {'title': '商品收藏', 'num': '35'},
    {'title': '店铺关注', 'num': '23'},
    {'title': '喜欢对内容', 'num': '12'},
    {'title': '浏览记录', 'num': '56'},
  ];
  List orderList = [
    {'name': '代付款', 'icon': 0xe624, 'orderIndex': 1},
    {'name': '待收货', 'icon': 0xe622, 'orderIndex': 2},
    {'name': '待评价', 'icon': 0xe61e, 'orderIndex': -1},
    {'name': '退换/售后', 'icon': 0xe619, 'orderIndex': -1},
    {'name': '我的订单', 'icon': 0xe8cd, 'orderIndex': 0},
  ];

  List moneyList = [
    {'title': '7993', 'name': '京豆', 'subText': '签到领京豆'},
    {'title': '11', 'name': '优惠券', 'subText': ''},
    {'title': '7', 'name': '白条', 'subText': '还款倒计时'},
    {'title': '1.77', 'name': '京东金条', 'subText': '秒批额度'},
    {'title': '2.3', 'name': '我的钱包', 'subText': ''}
  ];

  List toolsList = [
    {'title': '京东超市', 'icon': 'assets/images/tools/tool_1.png'},
    {'title': '京东电器', 'icon': 'assets/images/tools/tool_2.png'},
    {'title': '潮流服饰', 'icon': 'assets/images/tools/tool_3.png'},
    {'title': '免费水果', 'icon': 'assets/images/tools/tool_4.png'},
    {'title': '京东到家', 'icon': 'assets/images/tools/tool_5.png'},
    {'title': '生活服务', 'icon': 'assets/images/tools/tool_6.png'},
    {'title': '领京豆', 'icon': 'assets/images/tools/tool_7.png'},
    {'title': '领劵', 'icon': 'assets/images/tools/tool_8.png'},
    {'title': '借钱', 'icon': 'assets/images/tools/tool_9.png'},
    {'title': 'PLUS', 'icon': 'assets/images/tools/tool_10.png'},
  ];

  onScroll(offset) {
    double alpha = offset / appBarScrollOffset;

    if (alpha < 0) {
      alpha = 0;
    } else if (alpha > 1) {
      alpha = 0.9;
    }

    appBarAlpha.value = alpha;
  }
}
